import React from 'react';
import { Toast,Modal } from 'antd-mobile';

const prompt = Modal.prompt;

export default class Index extends React.Component {
    constructor(props){
        super(props)
        this.state={
            id: props.match.params.id,
            money: 0,
            pay_type:0,
        }
    }
	componentDidMount(){
		document.title = '订单详情'
        global.Ajax.hhtc_request("user/active_detail",{id: this.state.id}).then(data=>{
			if(data.code===1){
				this.setState(data.data)
			}
		})
	}
	// 赠送
	xh(){
        if(this.state.zeng_num<=0){
            return Toast.fail('赠送次数已用完!',1)
        }
		prompt(<p style={{fontWeight: 'bold',fontSize: 18,color: '#16B998',}}>赠送入场卡</p>, <p style={{textAlign: 'center',}}>可以赠送入场卡给好友哦</p>,[{
			text: '取消',
			onPress: value => new Promise((resolve) => {
				resolve();
			}),
        }, {
			text: '立即赠送',
			onPress: value => new Promise((resolve, reject) => {
				if(value!==''){
                    global.Ajax.hhtc_request("user/send_active",{id: this.state.id,phone: value}).then(data=>{
						if(data.code===1){
							Toast.success(data.msg,1)
							resolve();
						}else{
							Toast.fail(data.msg,1)
						}
					})
				}else{
                    Toast.fail('请输入被赠送人手机号!',1)
                }
			}),
        },], 'default', null, ['请输入对方手机号'])
	}
	render(){
		return(
			<div className='check_order order_detail_box' style={{minHeight: '100vh',background: '#F5F5F5',paddingBottom: 70,}}>
                <img alt='' src={require('../../imgs/dbg.png')} className='dbg' />
                <p className='p1'>购买成功</p>
                <p className='p2'>感谢您的购买</p>
                <img alt='' src={require('../../imgs/rccard.png')} className='rccard' />
                <div className='activity_row'>
                    <div>
                        <img alt='' src={this.state.img} className='' />
                        <div className='right'>
                            <p className='title'>{this.state.title}</p>
                            <p className='writer'>讲师：{this.state.author}</p>
                        </div>
                    </div>
                    <p>地址：<span>{this.state.address}</span></p>
                    <p>时间：<span>{this.state.time}</span></p>
                </div>
                <div className='order_info'>
                    <div className='row'>
                        <p>订单编号</p>
                        <span>{this.state.order_sn}</span>
                    </div>
                    <div className='row'>
                        <p>创建时间</p>
                        <span>{this.state.atime}</span>
                    </div>
                    <div className='row'>
                        <p>支付时间</p>
                        <span>{this.state.paytime}</span>
                    </div>
                </div>
                <dov className='order_pri_box'>
                    <p>订单金额</p>
                    {this.state.pay_type===1&&<span>免费</span>}
					{this.state.pay_type===2&&<span>￥{this.state.money*1}</span>}
					{this.state.pay_type===3&&<span>{this.state.money*1}<img alt='' src={require('../../imgs/hua.png')} style={{width: 14,height: 19,marginLeft:'5px'}} /></span>}
                </dov>
                {this.state.is_zeng===1&&<div className='activity_bott1'>
                    <p onClick={this.xh.bind(this)}>您有{this.state.zeng_num}个入场卡可以赠送，点击赠送</p>
                </div>}                
			</div>
		)
	}
}
